import express from 'express';
import tbApi from '../../lib/tbapi'; // 淘宝接口API
import CONFIG from '../../../config/config.config'; // CONFIG
// import { checkPermission } from '../../utils/utils'; // 工具类

const router = express.Router();

router.post('/', async function (Request, Response, next) {
  let param = Request.body
  // 获取商品详情
  tbApi.index({
    method: 'taobao.tbk.item.info.get', // 淘宝客商品详情查询
    num_iids: param.goodsId,
  }).then(res => {
    // console.log(res)
    if (res.error_response) {
      // 接口返回出错信息
      Response.status(300).send({ message: res.error_response.sub_msg || res.error_response.msg });
    } else {
      Response.json({
        data: {
          list: res.tbk_item_info_get_response.results.n_tbk_item[0]
        }
      });
    }
  })

  
});

module.exports = router;